package org.example.deadLock;

public class MyThread2 implements Runnable{
    @Override
    public void run() {
        synchronized (LockB.lockb){
            System.out.println(Thread.currentThread().getName()+"获取到了B锁。");
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (LockA.lockA){
                System.out.println(Thread.currentThread().getName()+"获取到了A锁。");
            }
        }
    }
}
